/*
    This is a set of libraries to assist in OpenGl and Other Applications
    Copyright (C) 2008  The Modular Engine Team

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HUDELEMENT_H
#define HUDELEMENT_H
#include "EngineCore.h"
#include "WindowModule.h"
#include "Math.h"
#include "OpenglModule.h"

// This will be the base class for HUD elements including,
// but not limited to Windows, Buttons, Textboxes, etc.

#undef CLASSDECL

#ifdef HUDMODULE
	#define CLASSDECL __declspec(dllexport)
#else
	#pragma comment( lib, "HUDModule.lib" )
	#define CLASSDECL __declspec(dllimport)
#endif

#define LOADCOLORS mvBaseColor = ModularEngine::HUDModule::getSingleton().getBaseColor(); \
	mvTextColor = ModularEngine::HUDModule::getSingleton().getTextColor(); \
	gl = &ModularEngine::OpenglModule::getSingleton(); \
	pParent = 0; \
	mbVisible = true;

namespace ModularEngine
{
	class HUDElement
	{
	protected:
		bool mbDraggable; // Can we drag the element?  Usually for windows.
		bool mbMouseDown; // Last known state of mouse. Left button.
		bool isMouseDown()
		{
			 // is the mouse still down?			
			return ModularEngine::WindowModule::getSingleton().isDown( 0 );
		}

		// Element colors
		Vector3d mvBaseColor;
		Vector3d mvTextColor;

		// Shortcut to opengl Module
		ModularEngine::OpenglModule *gl;

	public:
		// If not visible.  Don't draw :)
		bool mbVisible;

		// Parent Element:
		HUDElement *pParent;

		// For child elements only
		HUDElement *mpFocusedElement;

		// Position and dimensions for the element
		Vector2d mvPosition;
		Vector2d mvDimensions;

		// Set these as pure virtual functions
		virtual int initialize() = 0;
		virtual void draw() = 0;

		// mouse vPos is relative to the window position
		virtual void mouseInput( Vector2d vPos, UINT nDown ) = 0;

		// keyboard input
		virtual void keyboardInput( UINT nKey ) = 0;

		// Set button color scheme
		void setColors( Vector3d vBaseColor, Vector3d vTextColor )
		{
			mvBaseColor = vBaseColor;
			mvTextColor = vTextColor;
		}

	};
}

#endif
